package ca.skygazer.shared.coords;

import java.io.Serializable;

@SuppressWarnings("serial")
public class RaDecCoord implements Serializable {
	public double ra=0;  //in radians
	public double dec=0;  //in radians.
	
	public RaDecCoord(){
	}
	public RaDecCoord(double ra, double dec){
		this.ra=ra;
		this.dec=dec;
	}
	
	public AzAltCoord getAzAlt(double lst, LatLonCoord latLon){
		double alt=Math.asin(Math.sin(latLon.lat)*Math.sin(dec)+Math.cos(latLon.lat)*Math.cos(dec)*Math.cos(ra-lst));
		double a=Math.acos((Math.sin(dec)-Math.sin(alt)*Math.sin(latLon.lat))/
				(Math.cos(alt)*Math.cos(latLon.lat)));
		double az=a;
		if(Math.sin(ra-lst)<0) az=2*Math.PI-a;
		return new AzAltCoord(az,alt);
	}	
}
